﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using MuzoBlog.Core;

/// <summary>
/// Summary description for Post
/// </summary>
public class PostListControl : System.Web.UI.Control
{
    public int PageNumber { get; set; }

    public int PageSize { get; set; }

    protected override void Render(System.Web.UI.HtmlTextWriter writer)
    {
        StringBuilder sb = new StringBuilder();
        var posts = (from p in MuzoApp.Db.Posts
                     orderby p.PostDate ascending
                     select p).Take(10);

        foreach (var item in posts)
        {
            sb.AppendFormat("<div class=\"post\"><h1 class=\"title\"><a rel=\"bookmark\" href=\"{1}.aspx\" title=\"{0}\">{0}</a></h1>", item.Title, item.Slug);
            sb.Append("<div class=\"entry\">");
            sb.AppendFormat("<p>{0}</p>", item.Summary);
            sb.Append("</div><div class=\"meta\"><p class=\"links\"><a href=\"#\" class=\"more\">Read full article</a> <b>|</b> <a href=\"#\" class=\"comments\">Comments (32)</a></p></div></div>");
        }

        writer.Write(sb.ToString());
    }

}